solution#502
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
This submission requires changes because the main feature of the task—implementing CRUD functionality for categories—has not been started. The code appears to be from the previous lesson without the required updates. You'll need to create a Category model, add the API endpoints for it in src/createServer.js, and update the Expense model to use a foreign key to link to a category.
Additionally, the build is failing due to a database error. The Expense model is trying to reference a users table, but the User model creates a Users table (with a capital 'U'). In PostgreSQL, these names are case-sensitive. You can fix this by updating the reference in your Expense model:
// src/models/Expense.model.js
userId: {
type: DataTypes.INTEGER,
references: {
model: 'Users', // <-- Change this from 'users' to 'Users'
key: 'id',
},
// ...
},Please implement the category management feature and apply this fix to get the tests passing.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| category: { | ||
| type: DataTypes.STRING, | ||
| allowNull: true, | ||
| }, |
There was a problem hiding this comment.
To enable CRUD functionality for categories as required by the task, Category should be implemented as a separate model. Consequently, this Expense model should reference a category via a foreign key (e.g., categoryId) rather than using a simple string field. This architectural change is essential for managing categories independently.
| return app; | ||
| }; | ||
|
|
||
| module.exports = { createServer }; |
There was a problem hiding this comment.
The task requires implementing CRUD functionality for categories. This would involve creating a Category model, importing it here, and then adding the corresponding API endpoints (e.g., GET, POST, PATCH, DELETE for /categories) within this file. This implementation is currently missing.
| const models = { | ||
| User, | ||
| Expense, | ||
| }; | ||
|
|
||
| module.exports = { | ||
| models: { | ||
| User, | ||
| Expense, | ||
| }, | ||
| models, | ||
| User, | ||
| Expense, | ||
| }; |
There was a problem hiding this comment.
To meet the task requirements, a Category model needs to be created and integrated here. You should import the Category model, define its relationship with Expense (e.g., an Expense belongs to a Category), and add it to the models object and the exports.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Great work on implementing the category management feature! You've successfully set up the new models, associations, and API endpoints, addressing all previous feedback.
However, a change is needed before this can be approved. In src/index.js, the server is being started twice. The initial createServer().listen(5700, ...) call at the top of the file is redundant and can cause port conflicts and unpredictable application behavior.
Please remove this block. The server should only be started once, inside the async function start(), after the database connection is confirmed. Once that's fixed, your work will be ready!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| createServer().listen(5700, () => { | ||
| console.log('Server is running on localhost:5700'); | ||
| }); |
There was a problem hiding this comment.
This block starts a server instance on port 5700, but another server is started later in the start function on port 3000. This is redundant and can cause issues. The server should only be started once after the database connection is successfully established. Please remove this block.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Excellent work on this update! You've successfully addressed all the previous feedback, particularly in correcting the server startup logic. The project now fully meets all requirements, with a complete CRUD API for categories and proper integration with PostgreSQL. Your code is clean, well-structured, and all issues from the last review have been resolved. I am happy to approve your solution. Great job!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
No description provided.